package com.cn.mybatis.dao;

import com.cn.mybatis.pojo.OrderBean;
import com.cn.mybatis.pojo.UserBean;
import org.apache.ibatis.annotations.*;
import org.mybatis.caches.redis.RedisCache;

import java.util.List;

@CacheNamespace(implementation = RedisCache.class)
public interface IOrderDao {

    @Results({
            @Result(column = "id", property = "id"),
            @Result(column = "ordertime", property = "orderTime"),
            @Result(column = "total", property = "total"),
            @Result(column = "uid", property = "user", javaType = UserBean.class,
            one = @One(select = "com.cn.mybatis.dao.IUserDao.getById"))
    })
    @Select("select * from orders where id = #{id}")
    public List<OrderBean> getOneToOne(Integer id);

    @Select("select * from orders where uid = #{uid}")
    public List<OrderBean> getByUid(Integer uid);

}
